package com.moon.service.impl;

import com.moon.dao.ChinaMapper;
import com.moon.entity.China;
import com.moon.service.inte.ChinaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChinaServiceImpl implements ChinaService {
    @Autowired
    private ChinaMapper chinaMapper;

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public ChinaMapper getChinaMapper() {
        return chinaMapper;
    }

    public List<China> selectRoots() {
        String sql = "select * from china where pid=0";
        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<China>(China.class));
    }
}
